package com.wang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wang.domain.LargeCategory;
import com.wang.mapper.LargeCategoryMapper;
import com.wang.service.LargeCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author WangZai
 * @since 2023-05-06
 */
@Service
public class LargeCategoryServiceImpl extends ServiceImpl<LargeCategoryMapper, LargeCategory> implements LargeCategoryService {

    @Override
    public boolean addLargeCategory(LargeCategory category) {
        return this.save(category);
    }

    @Override
    public boolean deleteLargeCategory(Integer categoryId) {
        return this.removeById(categoryId);
    }

    @Override
    public LargeCategory getLargeCategoryById(Integer categoryId) {
        return this.getById(categoryId);
    }

    @Override
    public LargeCategory getLargeCategoryByName(String categoryName) {
        QueryWrapper<LargeCategory> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("large_category_name",categoryName);
        return this.getOne(queryWrapper);
    }


    @Override
    public List<LargeCategory> getLargeCategories() {
        return this.list();
    }
}
